home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 12, No. 01 (1991-01)(MindCraft Publishing)(Side A).zip
/
Nibble Volume 12, No. 01 (1991-01)(MindCraft Publishing)(Side A).po
/
UNPACK.S
< prev
Wrap
Text File
|
1996-12-24
|
6KB
|
180 lines
*------------------------------ *
* Universal Super Res picture *
* unpacker by Peter Stubbs *
*-------------------------------*
* MERLIN 816 ASSEMBLER *
*-------------------------------*
* Copyright (C) 1991 *
* MindCraft Publ. Corp. *
*-------------------------------*
*--------------------------------------------------
* Unpacks pictures packed with PAINTWORKS PLUS,
* DELUXEPAINT and PackBytes (from TOOL BOX)
*
* PLEASE NOTE:
* -----------
* 1. Can tell packed pic type from the AUX ID
*
* If AUX ID = 0 then is in PAINTWORKS PLUS format
* If AUX ID = 1 then is in PackBytes format
* If AUX ID = 2 then is in DELUXE PAINT format
*
* 2. The DELUXE PAINT format is also called APPLE
* PREFERRED format
*
* 3. Store AUX ID at PICTYPE before unpacking
*
* 4. To find AUX ID from BASIC do the following:-
*
* a). BLOAD UNPACK
* b). BLOAD <picname>,A$1400,T$C0
* c). CALL 942 (does a GET_FILE_INFO call)
* d). PEEK (957) gives the AUX ID
* e). If PEEK (970) <>0 it is ProDOS error code
*--------------------------------------------------
ORG $300
TR ADR
LINSAVE EQU $3 ;To hold value at NEWVIDEO
SIZEPTR EQU $4 ;Size of SuperRes pic
STARTPTR EQU $7 ;Ptr to start of pic
BUFFADR EQU $CE ;Bank 0 buffer start addr
NUMBYTES EQU $ED ;Number of bytes packed
NEWVIDEO EQU $C029
PICTYPE EQU $FE
SIZE EQU $9400-$1400 ;Max size of packed pic
SETUP LDA $C029
STA LINSAVE ;Save for later
ORA #%01000000 ;Linear mode on
STA $C029
LDA PICTYPE
BEQ PNTUNPAK ;PAINTWORKS format
CMP #$2 ;DELUXEPAINT format
BEQ DLXUNPAK
CMP #$1 ;PackBytes format
BNE EXIT ;Do nothing
JSR NATIVE ;NATIVE MODE
* Set up values to unpack the picture
MX %00
LDY #$0000 ;Buffer offset of zero
UNPAK LDA #$A000-$2000 ;Size of area to unpack
* Entry point for PAINTWORKS and DELUXEPAINT unpack
UNPAK2 STA SIZEPTR
STZ SIZEPTR+2 ;Zero high part of ptr
LDA #$E12000 ;Address of start of pic
STA STARTPTR
LDA #^$E12000
STA STARTPTR+2
TYA ;Move buffer offset to acc
CLC ;prepare to add $1400 to
ADC #$1400 ;get start address of data
STA BUFFADR ;and save for unpack code
* Now do the unpack
MX %00
PEA $0000 ;Space for result
PEA $0000 ;HI addr of BUFFER
LDA BUFFADR ;Get LO addr of BUFFER
PHA ; and put on stack
PEA #<SIZE ;Max size of pack buffer
PEA #^STARTPTR ;Pointer to word with start
PEA #<STARTPTR ; of area to unpack
PEA #^SIZEPTR ;Pointer to word with size
PEA SIZEPTR ; of area to unpack
LDX #$2703 ;_UnpackBytes tool call
JSL $E10000 ;Call the Tool Locator
PLA ;Discard no. bytes unpacked
EXIT JSR EMMODE ;EMULATION MODE ON
RTS ;Exit
* PAINTWORKS PLUS Unpack setup
MX %11
PNTUNPAK STZ LOOP+1 ;Make start of palette data
JSR MOVEPAL ; $1400 then move it across
STZ $1409 ;Flag as 320 mode
LDA #$02 ;Paintworks packed pic data
PHA ; is offset $222 bytes from
LDA #$22 ; the start of the buffer
PHA ;Note these are 8 bit PHA's
BRA COMMON ;Go to common unpack code
* DELUXE PAINT Unpack setup
DLXUNPAK LDA #$0F ;Pal. data starts at $140F
STA LOOP+1 ; so patch pal. start addr.
JSR MOVEPAL ; then move the palette
LDA #$03 ;Deluxepaint packed data
PHA ; is offset $351 bytes from
LDA #$51 ; the start of the buffer
PHA ;Note these are 8 bit PHA's
* CHANGE ALL POINTERS TO POINT AT PALETTE 0
COMMON CLC ;Start with zero in carry
LDA $1409 ;Check for 320 or 640 mode
BPL NORM ;If 320 mode we're done
SEC ;Put 1 in Carry for 640
NORM LDX #$0
TXA ;Start with SCB of zero
ROR ;Sets SCB = $80 if carry set
MORE STAL $E19D00,X ;Set palette zero and
INX ; correct res mode in SCB's
BNE MORE
MX %00
JSR NATIVE ;Then do a 16 bit PLY
PLY ;Y=$222 or $351 offset
LDA #$9D00-$2000 ;Size of area to unpack
BRA UNPAK2 ;Go unpack the picture
* MOVE PALETTE ACROSS - USED BY DLXUNPAK & PNTUNPAK
MX %11
MOVEPAL LDX #$00
LOOP LDA $1400,X ;Patched by caller
STAL $E19E00,X
INX
CPX #$21
BNE LOOP
RTS
MX %00
NATIVE CLC ;NATIVE MODE ON
XCE
REP #$30
RTS
EMMODE SEC ;EMULATION MODE ON
XCE
MX %11
LDA LINSAVE
STA $C029
RTS
* Code to do a GET_FILE_INFO to find AUX ID
INFO JSR $BF00 ;Call ProDOS MLI
DFB $C4 ;Get file info value
DA PARMS ;Address of paramters
STA ERR ;A=0 If no error
RTS
PARMS DFB $A ;No. of parameters
PATHNAME DA $280 ;ProDOS pathname buffer
ACCESS DS 1
TYPE DS 1
AUXTYPE DS 2 ;AUX ID
STORAGE DS 1
USED DS 2
MODDATE DS 2
MODTIME DS 2
CREDATE DS 2
CRETIME DS 2
ERR DS 1 ;ProDOS error code
LST OFF